package com.zzy.sample.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzy.sample.entity.User;
import com.zzy.sample.mapper.UserMapper;
import com.zzy.transaction.context.TransactionMeta;
import com.zzy.transaction.manager.TransactionCoordinator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Slf4j
public class UserService extends ServiceImpl<UserMapper, User> {

    @Transactional
    @Override
    public boolean save(User entity) {
        TransactionMeta transactionMeta = TransactionCoordinator.get();
        String executeId = transactionMeta.getExecuteId();
        entity.setExecuteId(executeId);
        return super.save(entity);
    }
}
